jQuery(function($){
    $.datepicker.regional['es'] = {
        closeText: 'Cerrar',
        prevText: '&#x3c;Ant',
        nextText: 'Sig&#x3e;',
        currentText: 'Hoy',
        monthNames: ['Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre'],
        monthNamesShort: ['Ene','Feb','Mar','Abr','May','Jun','Jul','Ago','Sep','Oct','Nov','Dic'],
        dayNames: ['Domingo','Lunes','Martes','Mi&eacute;rcoles','Jueves','Viernes','S&aacute;bado'],
        dayNamesShort: ['Dom','Lun','Mar','Mi&eacute;','Juv','Vie','S&aacute;b'],
        dayNamesMin: ['Do','Lu','Ma','Mi','Ju','Vi','S&aacute;'],
        weekHeader: 'Sm',
        dateFormat: 'dd/mm/yy',
        firstDay: 1,
        isRTL: false,
        showMonthAfterYear: false,
        yearSuffix: ''};
    $.datepicker.setDefaults($.datepicker.regional[userLocale]);
});

jQuery(document).ready(function() {    
	$("#blogCalendar").datepicker({
		beforeShowDay: customizeCells,
		onSelect: clickCell,
		dateFormat: "dd/mm/yy"
	});
});

function customizeCells(day) {	
	if ( dates[$.datepicker.formatDate("dd/mm/yy", day)] ) {
		return [true, "active", ""];
	}
	else {
		return [false, "", ""];
	}
}

function clickCell(day) {
	document.location.href = window.location.href.split('?')[0] + '?day=' + day;
}